package com.ruoyi.project.module.lyq;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.YqgBaseinfo;
import com.ruoyi.project.service.IYqgBaseinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 人员基础信息Controller
 * 
 * @author dr
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/lyq/baseinfo")
public class LyqYqgBaseinfoController extends BaseController
{
    @Autowired
    private IYqgBaseinfoService yqgBaseinfoService;

    /**
     * 查询人员基础信息列表
     */
//    @RequiresPermissions("project:baseinfo:list")
    @GetMapping("/list")
    public TableDataInfo list(YqgBaseinfo yqgBaseinfo)
    {
        startPage();
        List<YqgBaseinfo> list = yqgBaseinfoService.selectYqgBaseinfoList(yqgBaseinfo);
        return getDataTable(list);
    }

    /**
     * 导出人员基础信息列表
     */
//    @RequiresPermissions("project:baseinfo:export")
    @Log(title = "人员基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqgBaseinfo yqgBaseinfo)
    {
        List<YqgBaseinfo> list = yqgBaseinfoService.selectYqgBaseinfoList(yqgBaseinfo);
        ExcelUtil<YqgBaseinfo> util = new ExcelUtil<YqgBaseinfo>(YqgBaseinfo.class);
        util.exportExcel(response, list, "人员基础信息数据");
    }

    /**
     * 获取人员基础信息详细信息
     */
//    @RequiresPermissions("project:baseinfo:query")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(yqgBaseinfoService.selectYqgBaseinfoByID(ID));
    }

    /**
     * 新增人员基础信息
     */
//    @RequiresPermissions("project:baseinfo:add")
    @Log(title = "人员基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqgBaseinfo yqgBaseinfo)
    {
        return toAjax(yqgBaseinfoService.insertYqgBaseinfo(yqgBaseinfo));
    }

    /**
     * 修改人员基础信息
     */
//    @RequiresPermissions("project:baseinfo:edit")
    @Log(title = "人员基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqgBaseinfo yqgBaseinfo)
    {
        return toAjax(yqgBaseinfoService.updateYqgBaseinfo(yqgBaseinfo));
    }

    /**
     * 删除人员基础信息
     */
//    @RequiresPermissions("project:baseinfo:remove")
    @Log(title = "人员基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(yqgBaseinfoService.deleteYqgBaseinfoByIDs(IDs));
    }
}
